@use "sass:color";
@use "sass:list";

.course-table {
  text-align: center;
}

.course-table-header {
  display: flex;
  font-weight: bold;
}

.course-table-header-item {
  flex: 1;
  flex-basis: 0;
  border-left: 1px dashed var(--border-color);

  .time {
    font-size: 14px;
  }
}

.course-table-row {
  display: flex;

  &:last-child {
    .course-table-item {
      border-bottom: 1px dashed var(--border-color);
    }
  }
}

.course-row-header {
  flex: 0;
  flex-basis: 24px;
  padding: 16px 0;
  border-bottom: 1px dashed var(--border-color);

  .course-table-header & {
    padding: 0;
  }
}

.course-table-item {
  display: flex;
  flex: 1;
  flex-basis: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;

  border-top: 1px dashed var(--border-color);
  border-left: 1px dashed var(--border-color);

  &:first-child {
    border-left: none;
    font-weight: bold;
  }
}

.course-table-course {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  margin: 4px 2px;
  border: 1px solid var(--border-color);
  border-radius: 4px;

  font-size: 13px;
  word-break: break-all;
}

$colors:
  hsl(0deg 67% 45%), hsl(30deg 67% 45%), hsl(60deg 67% 45%), hsl(90deg 67% 45%),
  hsl(120deg 67% 45%), hsl(150deg 67% 45%), hsl(180deg 67% 45%),
  hsl(210deg 67% 45%), hsl(240deg 67% 45%), hsl(270deg 67% 45%),
  hsl(300deg 67% 45%), hsl(330deg 67% 45%), hsl(0deg 0% 0%);

@each $color in $colors {
  $index: list.index($colors, $color) - 1;

  .course-item#{$index} {
    background-color: color.scale($color, $lightness: 90%);
    color: color.scale($color, $lightness: -10%);

    @media (prefers-color-scheme: dark) {
      background-color: color.scale($color, $lightness: -75%);
      color: color.scale($color, $lightness: 20%);
    }

    &.hover {
      background-color: color.scale($color, $lightness: 75%);

      @media (prefers-color-scheme: dark) {
        background-color: color.scale($color, $lightness: -60%);
      }
    }
  }
}
